<template>
  <el-card class="blacklist-appeal">
    <h2>黑名单申诉</h2>
    <el-form :model="form" ref="formRef" label-width="120px">
      <el-form-item label="申诉原因">
        <el-input v-model="form.reason" type="textarea" rows="4" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitAppeal">提交申诉</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { ElMessage } from 'element-plus';
import { appealBlacklist } from '../../api/blacklist';

const formRef = ref(null);
const form = ref({
  reason: ''
});

const submitAppeal = async () => {
  try {
    await formRef.value.validate();
    const res = await appealBlacklist(form.value);
    if (res.code === 0) {
      ElMessage.success('申诉提交成功，请等待处理');
      form.value.reason = '';
    } else {
      ElMessage.error('申诉提交失败，请稍后重试');
    }
  } catch (error) {
    ElMessage.error('表单验证失败，请检查输入');
  }
};
</script>

<style scoped>
.blacklist-appeal {
  padding: 16px;
}
</style>